<?php
class subscribe{
	public function init($params=array()){
		$this->db=$this->yum->library($this->yum->vars('app','database'));
		$this->prefix=$this->yum->vars('app','prefix');
	}
	public function GSubscribe($params=array()){
    	return $this->db->select($this->prefix.'subscribe AS A',$params);
    }
    public function GSubscribeM($params=array()){
    	$table=$this->prefix.'subscribe AS A';
    	$table.=' LEFT JOIN '.$this->prefix.'mmstr AS B ON (A.train=B.train AND A.leave=B.date)';
    	if(!isset($params['select'])){
    		$params['select']='A.*,B.mmstr,COUNT(*) AS unite';
    	}
    	return $this->db->select($table,$params);
    }
    public function GSubscribeFull($params=array()){
    	$table=$this->prefix.'subscribe AS A';
    	$table.=' LEFT JOIN '.$this->prefix.'member AS B ON A.member=B.id';
    	if(!isset($params['select'])){
    		$params['select']='A.*,B.user AS member';
    	}
    	return $this->db->select($table,$params);
    }
	public function ISubscribe($params,$mode=0){
		return $this->db->insert($this->prefix.'subscribe',$params,$mode);
	}
	public function USubscribe($params){
		return $this->db->update($this->prefix.'subscribe',$params);
	}
	public function DSubscribe($params){
		return $this->db->delete($this->prefix.'subscribe',$params);
	}
}
?>